package com.learn.kotlinlearndemolist.base;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.learn.kotlinlearndemolist.R;

public abstract class BaseDialog<B extends ViewDataBinding> extends Dialog {
    protected B mBinding;
    protected Context mContext;

    /**
     * Constructor.
     *
     * @param context Context
     */
    public BaseDialog(@NonNull Context context) {
        super(context, R.style.normalDialog);
        mContext = context;
        mBinding = DataBindingUtil.inflate(LayoutInflater.from(mContext),
                this.getResId(), null, false);
        setContentView(mBinding.getRoot());
        initView();
    }

    protected abstract void initView();

    @LayoutRes
    protected abstract int getResId();

    public View getView() {
        return mBinding.getRoot();
    }
}